package com.tristia.entity.util;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import com.tristia.dao.GenericDao;
import com.tristia.entity.Book;

public class BookDataLoader {
	private List<Book> books = new ArrayList<Book>();
	@Resource
	GenericDao<Book, Long> bookDao;
	
	public void loadData() {
		for (Book book : books) {
			bookDao.save(book);
		}
		books.clear();
		books = null;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}
	
	public void init() {
		loadData();
	}
}
